﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 人事工资管理系统
{
    public partial class frmAddUserCheck : Form
    {
        public frmAddUserCheck()
        {
            InitializeComponent();
        }
        PMSClass.DBOperate operate = new PMSClass.DBOperate();
        SqlConnection conn = PMSClass.DBConnection.MyConnection();
        private void toolStripLabel1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text.Trim() == "" || textBox2.Text.Trim() == "" ||
               textBox3.Text.Trim() == "" || textBox4.Text.Trim() == "" ||
               textBox5.Text.Trim() == "" || textBox6.Text.Trim() == "" ||
               textBox7.Text.Trim() == "" || dateTimePicker1.Text.Trim() == "")
            {
                MessageBox.Show("请将信息填写完整", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                string strSql = "insert into tb_check(PID,Pname,Pdep,PKpcontent,PKpResult,PKpscore,PKppeople,PKpdate)values('" + comboBox1.Text.Trim() + "','" + textBox2.Text.Trim() + "','" +textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text.Trim() + "','" + textBox6.Text + "','" + textBox7.Text.Trim() + "','" + dateTimePicker1.Text.Trim()  + "')";
                int num = operate.OperateData(strSql);
                if (num > 0)
                {
                    MessageBox.Show("员工考评成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }

        private void toolStripLabel2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str = "select * from tb_employee where employeeID='" + comboBox1.Text + "'";
            DataSet ds = operate.GetTable(str);
            ds.Dispose();
            textBox2.Text = ds.Tables[0].Rows[0][2].ToString();
            textBox3.Text = ds.Tables[0].Rows[0][4].ToString();

            
        }

        private void frmAddUserCheck_Load(object sender, EventArgs e)
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from tb_employee", conn);
            SqlDataReader sdr = cmd.ExecuteReader();
            while (sdr.Read())
            {
                comboBox1.Items.Add(sdr["employeeID"].ToString());
            }
            sdr.Close();
            conn.Close();
        }
    }
}
